package cn.dengta.webapp.trade.dto;

import cn.dengta.webapp.trade.entity.UserIntegral;
import cn.dengta.webapp.user.entity.User;
import cn.dengta.webapp.user.model.Gender;
import lombok.*;
import me.codeplayer.util.X;

@Getter
@Setter
public class UserIntegralDTO extends UserIntegral {

	/** 用户信息 */
	@Setter(AccessLevel.NONE)
	private User user;
	/** 推广员ID */
	private Long agentId;

	public void setNickname(String nickname) {
		user().setNickname(nickname);
	}

	public void setUId(Long id) {
		user().setId(id);
	}

	public void setAvatar(String avatar) {
		user().setAvatar(avatar);
	}

	public void setGender(Integer gender) {
		user().setGender(Gender.of(gender));
	}

	private User user() {
		return user = X.getElse(user, User::new);
	}

}
